/* 

Sarah F. Anzia and Terry M. Moe
July 19, 2018
This code reproduces the numerical results in 
"Interest Groups on the Inside: The Governance of Public Pension Funds"
In Perspectives on Politics

*/

* Load data: "Anzia_Moe_PensionBoards_Data_7_19_18.dta"

* FIGURE 1
hist pctemployeetotal, frequency bin(20)
hist pctemployee, frequency bin(20)
hist pctapptemployee, frequency bin(20)
hist pctexofficio, frequency bin(20)
hist pctapptemployer, frequency bin(20)
hist pctcitizenother, frequency bin(20)

* For figures in the text
codebook ppd_id if pctemployeetotal==0
codebook ppd_id if pctemployeetotal~=0 & pctemployeetotal~=.
codebook pctemployee if pctemployee~=0 & pctemployee~=.
codebook pctapptemployee if pctapptemployee~=0 & pctapptemployee~=.
codebook ppd_id if pctexofficio==0
di (1526-447)/1526
codebook pctapptemployer if pctapptemployer==0
di 779/1526
codebook ppd_id if pctcitizenother==0 & pctcitizenother~=.
codebook pctcitizenother if pctcitizenother~=0 & pctcitizenother~=.

* TABLE 1, COLUMN 1: discount rate 
xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother union_pc  ///
genrev_cpi_pctchg i.year, cluster(boardID)

test pctemployee=pctapptemployee

summarize discountrate, detail

di (2/3)*0.0063448
di (0.77-0.08)*.0055603

* TABLE 1, COLUMN 2: % ARC 
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv i.year if pctarc<1.5, cluster(boardID)

di -.104413*(2/3)
di -.1644318*(.77-.08)

* TABLE 1, COLUMN 3: % ARC
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

* TABLE 1, COLUMN 4: % ARC with interaction
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv legis_union i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

lincom legisinterv + .0796733*legis_union
lincom legisinterv +  .7654165*legis_union
lincom (.7654165*union_pc) - (.0796733*union_pc)
lincom (.7654165*union_pc + .7654165*legis_union) - (.0796733*union_pc + .0796733*legis_union)

* FIGURE 2 
collapse (mean) union_pc pctemployee, by(stabbr)
* here is the code to produce the figure
graph bar (asis) pctemployee, over(stabbr, sort(union_pc))

* re-load "Anzia_Moe_PensionBoards_Data_7_19_18.dta"

* FIGURE 3: Union membership and % ARC paid, by legislative involvement
lowess pctarc union_pc if pctarc<1.5 & statutecont==0, by(legisinterv)

* TABLE 2, COLUMN 1: discount rate, party of governor
* independent governors coded as non-Democrats
xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother demgov union_pc  ///
genrev_cpi_pctchg i.year, cluster(boardID)

* TABLE 2, COLUMN 2: % ARC
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother demgov ///
union_pc genrev_cpi_pctchg legisinterv legis_union demlegis legis_demlegis i.year ///
if pctarc<1.5 & statutecont==0, cluster(boardID)

* TABLE 2, COLUMN 3: pre-post recession, discount rate
xi: reg discountrate pctemployee scope_employee pctapptemployee pctapptemployer pctcitizenother union_pc  ///
scope_union genrev_cpi_pctchg i.year, cluster(boardID)

* effect of union before recession
lincom (.77*union_pc - .08*union_pc)
* effect of union after recession
lincom (.77*union_pc - .08*union_pc) + (.77*scope_union - .08*scope_union)
* change in effect of union from before to after recession
lincom (.77*scope_union - .08*scope_union)

* TABLE 2, COLUMN 4: pre-post recession, % ARC paid
xi: reg pctarc pctemployee scope_employee pctapptemployee pctapptemployer pctcitizenother ///
union_pc scope_union legisinterv ///
legis_union scope_legis scope_legis_union genrev_cpi_pctchg ///
i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

* effect of union before recession, no legislature
lincom (.77*union_pc - .08*union_pc)
* effect of union after recession, no legislature
lincom (.77*union_pc - .08*union_pc) + (.77*scope_union - .08*scope_union)
* change in effect of union from before to after recession, no legislature
lincom (.77*scope_union - .08*scope_union)

* effect of union before recession, with legislature
lincom (.77*union_pc - .08*union_pc) + (.77*legis_union - 0.08*legis_union)
* effect of union after recession, with legislature
lincom (.77*union_pc - .08*union_pc) + (.77*scope_union - .08*scope_union) + ///
(.77*legis_union - 0.08*legis_union) + (.77*scope_legis_union - .08*scope_legis_union)
* change in effect of union from before to after recession, with legislature
lincom (.77*scope_union - .08*scope_union) + (.77*scope_legis_union - .08*scope_legis_union)


*** ONLINE APPENDIX

* FIGURE A1: scatter of discount rate and % ARC
twoway (scatter pctarc discountrate if pctemployee==0 & pctarc<1.5 & statutecont==0, mcolor(black) ///
msymbol(circle_hollow)) (scatter pctarc discountrate if pctemployee>0 & pctarc<1.5 & ///
statutecont==0, mcolor(black) msymbol(lgx))

* TABLE A1: ACTIVE AND RETIRED EMPLOYEE TRUSTEES, column 1
xi: reg discountrate pctactiveemployee pctretiredemployee pctgeneralemployee ///
pctapptemployee pctapptemployer pctcitizenother union_pc  ///
genrev_cpi_pctchg i.year, cluster(boardID)

test pctactiveemployee = pctretiredemployee
test pctactiveemployee = pctgeneralemployee
test pctretiredemployee = pctgeneralemployee
test pctretiredemployee = pctgeneralemployee = pctactiveemployee 

* TABLE A1, COLUMN 2: active versus retired, % ARC
xi: reg pctarc pctactiveemployee pctretiredemployee pctgeneralemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv i.year ///
if pctarc<1.5, cluster(boardID)

test pctactiveemployee = pctretiredemployee
test pctactiveemployee = pctgeneralemployee
test pctretiredemployee = pctgeneralemployee
test pctretiredemployee = pctgeneralemployee = pctactiveemployee 

* TABLE A1, COLUMN 3: active versus retired, % ARC
xi: reg pctarc pctactiveemployee pctretiredemployee pctgeneralemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv legis_union i.year ///
if pctarc<1.5 & statutecont==0, cluster(boardID)

test pctactiveemployee = pctretiredemployee
test pctactiveemployee = pctgeneralemployee
test pctretiredemployee = pctgeneralemployee
test pctretiredemployee = pctgeneralemployee = pctactiveemployee 

* TABLE A2: ADDITIONAL CONTROLS

* column 1
xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother union_pc  ///
genrev_cpi_pctchg lntotaldebt_cpi_percap pubsafety school pctexpert ///
SocSecCovered i.year, cluster(boardID)

* column 2
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg lntotaldebt_cpi_percap legisinterv pubsafety school pctexpert ///
SocSecCovered i.year if pctarc<1.5, cluster(boardID)

* column 3
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg lntotaldebt_cpi_percap legisinterv pubsafety school pctexpert  ///
SocSecCovered i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

* column 4
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg lntotaldebt_cpi_percap legisinterv legis_union pubsafety school pctexpert ///
SocSecCovered i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

* APPENDIX TABLE A3, COLUMN 1
xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother union_pc  ///
genrev_cpi_pctchg return5yr i.year, cluster(boardID)

* Table A3, Column 2
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv return5yr i.year if pctarc<1.5, cluster(boardID)

* Table A3, Column 3
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv return5yr i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

* TABLE A3, COLUMN 4
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv legis_union return5yr i.year if pctarc<1.5 & statutecont==0, cluster(boardID)

* TABLE A4: LIST OF CHANGES TO SHARE OF ELECTED EMPLOYEE TRUSTEES WITHIN PLANS 2001-2014
list planname pctemployee chgpctemployee if year==2014 & chgpctemployee~=0 

* TABLE A5: PLAN FE MODELS, COLUMN 1
xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
genrev_cpi_pctchg i.ppd_id i.year, cluster(ppd_id)

* TABLE A5: PLAN FE MODELS, COLUMN 3
xi: reg discountrate majemployee pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
genrev_cpi_pctchg i.ppd_id i.year, cluster(ppd_id)

* TABLE A5: PLAN FE MODELS, COLUMN 2
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
genrev_cpi_pctchg legisinterv ///
I.ppd_id i.year if pctarc<1.5 & statutecont==0, cluster(ppd_id)

* TABLE A5: PLAN FE MODELS, COLUMN 4
xi: reg pctarc majemployee pctemployee pctapptemployee pctapptemployer pctcitizenother ///
genrev_cpi_pctchg legisinterv ///
I.ppd_id i.year if pctarc<1.5 & statutecont==0, cluster(ppd_id)

* TABLE A6, COLUMN 1 - OUTLIERS IN
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
union_pc genrev_cpi_pctchg legisinterv i.year ///
if onetimecont~=1, cluster(boardID)

* TABLE A6, COLUMN 2 - OUTLIERS IN
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
union_pc genrev_cpi_pctchg legisinterv i.year ///
if onetimecont~=1 & statutecont==0, cluster(boardID)

* TABLE A7, COLUMN 1: funding ratios
xi: reg fundedratio pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv i.year, cluster(boardID)

* TABLE A7, COLUMN 2: funding ratio
xi: reg fundedratio pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv legis_union i.year if statutecont==0, cluster(boardID)

* TABLE A8, COLUMN 1
collapse (mean) discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
union_pc genrev_cpi_pctchg, by(ppd_id planname stabbr boardID)

xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother union_pc  ///
genrev_cpi_pctchg, cluster(boardID)
test pctemployee=pctapptemployee

* re-load "Anzia_Moe_PensionBoards_Data_7_19_18.dta"
* Table A8, Column 2
keep if pctarc<1.5
collapse (mean) pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
union_pc genrev_cpi_pctchg (median) legisinterv, by(ppd_id planname stabbr boardID)

xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv, cluster(boardID)

* Table A8, Column 3
* re-load "Anzia_Moe_PensionBoards_Data_7_19_18.dta"
keep if pctarc<1.5
keep if statutecont==0
collapse (mean) pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother  ///
union_pc genrev_cpi_pctchg (median) legisinterv, by(ppd_id planname stabbr boardID)

xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv, cluster(boardID)

gen legis_union = legisinterv*union_pc

xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv legis_union, cluster(boardID)

* Table A9, column 1
* re-load "Anzia_Moe_PensionBoards_Data_7_19_18.dta"
xi: reg discountrate pctemployee pctapptemployee pctapptemployer pctcitizenother ///
recentdemgov c.recentdemgov#c.pctapptemployee c.recentdemgov#c.pctapptemployer c.recentdemgov#c.pctcitizenother ///
union_pc genrev_cpi_pctchg i.year, cluster(boardID)

* Table A9, column 2
xi: reg pctarc pctemployee pctapptemployee pctapptemployer pctcitizenother ///
recentdemgov c.recentdemgov#c.pctapptemployee c.recentdemgov#c.pctapptemployer c.recentdemgov#c.pctcitizenother ///
union_pc genrev_cpi_pctchg legisinterv legis_union demlegis legis_demlegis i.year ///
if pctarc<1.5 & statutecont==0, cluster(boardID)

